export default {
  // 为当前模块开启命名空间
  namespaced: true,

  // 模块的 state 数据
  state: () => ({
    address: uni.getStorageSync('address') || {},
    token:uni.getStorageSync('token') || '',
    userInfo:uni.getStorageSync('userInfo') || {}
  }),

  // 模块的 mutations 方法
  mutations: {
    updateToken(state,token){
      state.token = token
      uni.setStorageSync('token',token)
    },
    updateUserInfo(state,userInfo){
      state.userInfo = userInfo
      uni.setStorageSync('userInfo',userInfo)
      // console.log(state.userInfo)
    },
    setAddress(state, address) {
      state.address = address
      uni.setStorageSync('address',address)
    }
  },

  // 模块的 getters 属性
  getters: {
    addstr(state) {
      return state.address.provinceName ? `${state.address.provinceName},${state.address.cityName},${state.address.countyName},${state.address.detailInfo}` : '';
    }
  }
}
